
/****** Object:  StoredProcedure [proc_DailySalesLoadByPrimaryKey]    Script Date: 21/3/2015 6:45:12 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_DailySalesLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_DailySalesLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_DailySalesLoadByPrimaryKey]
(
	@DailySaleID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[DailySaleID],
		[DailySaleDesc],
		[DailySalePaid],
		[DailySaleDate],
		[DailySaleTime]
	FROM [DailySales]
	WHERE
		([DailySaleID] = @DailySaleID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_DailySalesLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_DailySalesLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_DailySalesLoadAll]    Script Date: 21/3/2015 6:45:12 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_DailySalesLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_DailySalesLoadAll];
GO

CREATE PROCEDURE [proc_DailySalesLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[DailySaleID],
		[DailySaleDesc],
		[DailySalePaid],
		[DailySaleDate],
		[DailySaleTime]
	FROM [DailySales]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_DailySalesLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_DailySalesLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_DailySalesUpdate]    Script Date: 21/3/2015 6:45:12 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_DailySalesUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_DailySalesUpdate];
GO

CREATE PROCEDURE [proc_DailySalesUpdate]
(
	@DailySaleID int,
	@DailySaleDesc nvarchar(250) = NULL,
	@DailySalePaid float = NULL,
	@DailySaleDate nvarchar(50) = NULL,
	@DailySaleTime nvarchar(50) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [DailySales]
	SET
		[DailySaleDesc] = @DailySaleDesc,
		[DailySalePaid] = @DailySalePaid,
		[DailySaleDate] = @DailySaleDate,
		[DailySaleTime] = @DailySaleTime
	WHERE
		[DailySaleID] = @DailySaleID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_DailySalesUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_DailySalesUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_DailySalesInsert]    Script Date: 21/3/2015 6:45:12 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_DailySalesInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_DailySalesInsert];
GO

CREATE PROCEDURE [proc_DailySalesInsert]
(
	@DailySaleID int = NULL output,
	@DailySaleDesc nvarchar(250) = NULL,
	@DailySalePaid float = NULL,
	@DailySaleDate nvarchar(50) = NULL,
	@DailySaleTime nvarchar(50) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [DailySales]
	(
		[DailySaleDesc],
		[DailySalePaid],
		[DailySaleDate],
		[DailySaleTime]
	)
	VALUES
	(
		@DailySaleDesc,
		@DailySalePaid,
		@DailySaleDate,
		@DailySaleTime
	)

	SET @Err = @@Error

	SELECT @DailySaleID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_DailySalesInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_DailySalesInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_DailySalesDelete]    Script Date: 21/3/2015 6:45:12 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_DailySalesDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_DailySalesDelete];
GO

CREATE PROCEDURE [proc_DailySalesDelete]
(
	@DailySaleID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [DailySales]
	WHERE
		[DailySaleID] = @DailySaleID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_DailySalesDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_DailySalesDelete Error on Creation'
GO
